import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import AutoImport from 'unplugin-auto-import/vite';
import vueJsx from '@vitejs/plugin-vue-jsx';
import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers';
import {visualizer} from "rollup-plugin-visualizer";

// https://vitejs.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          'table-header-sort-bg': '#f1f5f9',
          'table-body-sort-bg': 'inherit',
          'table-header-bg': '#f1f5f9',
          'background-color-light': '#f8fafc',
        },
        javascriptEnabled: true
      },
    },
  },

  server: {
    port: 9999,
    host: true,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:20000',
        changeOrigin: false,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
    }
  },

  plugins: [
    vue(),
    vueJsx(),

    // https://github.com/antfu/unplugin-auto-import
    AutoImport({
      imports: [
        'vue',
        'vue-router',
        {
          'ant-design-vue': [
            'message',
            'Modal'
          ]
        }
      ],
      dirs: [
        'src/composables'
      ],
      dts: 'src/auto-imports.d.ts',
    }),


    // https://github.com/antfu/unplugin-vue-components
    Components({
      resolvers: [AntDesignVueResolver({
        importStyle: 'less'
      })],
      dts: 'src/components.d.ts'
    }),

    // https://github.com/btd/rollup-plugin-visualizer
    visualizer(),
  ]
})
